---
id: 6557746aad2844a0cd864e12
title: الخطوة 22
challengeType: 20
dashedName: step-22
---

# --description--

While the algorithm explores the graph, it should keep track of the currently known shortest distance between the starting node and the other nodes.

Before your `for` loop, create a new variable named `distances` and assign it an empty dictionary.

# --hints--

You should have a `distances` variable.

```js
({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s*)distances\s*=.*(?=^\1for.*:)/ms));
  }
})
```

Your `distances` variable should be an empty dictionary.

```js
({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s*)distances\s*=\s*\{\s*\}.*(?=^\1for.*:)/ms));
  }
})
```

# --seed--

## --seed-contents--

```py
my_graph = {
    'A': [('B', 3), ('D', 1)],
    'B': [('A', 3), ('C', 4)],
    'C': [('B', 4), ('D', 7)],
    'D': [('A', 1), ('C', 7)]
}

--fcc-editable-region--
def shortest_path(graph, start):
    unvisited = []
    for node in graph:
        unvisited.append(node)
--fcc-editable-region--
```
